package two.chapter_1.c1_4;

import edu.princeton.cs.algs4.StdOut;
import edu.princeton.cs.algs4.StdRandom;

import java.util.Arrays;

public class Ex1_4_10 {


    public static void main(String [] args){
        int MAX=100;
        int N=10000;
        final int[] a=new int[N];
        for (int i=0;i<N;i++){
            a[i]=StdRandom.uniform(MAX);
        }
        //int a[]={1,2,2,2,3};

        Arrays.sort(a);
        new Thread(new Runnable() {
            @Override
            public void run() {
                Stopwatch stopwatch2=new Stopwatch();
                //返回和key相等的最小的index
                StdOut.println(BinarySearch.rankMin(55,0,a.length,a)+"  "+stopwatch2.elapseTime());//2

            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                Stopwatch stopwatch=new Stopwatch();
                StdOut.println(BinarySearch.rank(55,0,a.length,a)+"  "+stopwatch.elapseTime());//2
            }
        }).start();





    }
}
